<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
  <head>
	  <link rel="shortcut icon" href="http://localhost:8080${pageContext.request.contextPath}/img/logo.jpg">
	  <title>任务列表</title>
<!-- Bootstrap -->
		<link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
		<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
		<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
		<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
		<style type="text/css">
			/* 选择器：1.标签 2.class 3.id */
			.lbimg{
				width: 100%;
			}
			.dvfooter{
				position: absolute;
				bottom: 2px;
				height: 40px;
				background-color: #0062CC;
				width: 100%;
			}
			/*表格样式*/
			table{
				table-layout:fixed;
				word-wrap:break-word;
			}
			th {
				text-align: center;
			}
			td {
				white-space:nowrap;
				overflow:hidden;
				text-overflow: ellipsis;
				text-align: center;
			}
		</style>
  </head>
  <body>
    <div class="container">
    	<div class="row clearfix">
    	    <div class="col-md-12 column">
    		 	<nav class="navbar navbar-default" role="navigation">
                    <div class="navbar-header">
                    	<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
							 <span class="sr-only">Toggle navigation</span>
							 <span class="icon-bar"></span>
							 <span class="icon-bar"></span>
							 <span class="icon-bar"></span>
						</button>
						<img src="http://localhost:8080${pageContext.request.contextPath}/img/label.jpg" class="navbar-brand" style="">
					</div>
					<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav navbar-right">
							<li><a href="${pageContext.request.contextPath}/index.jsp">首页</a></li>
							<li class="active">
								<c:if test="${sessionScope.user!=null}">
									<a href="#">任务</a>
								</c:if>
								<c:if test="${sessionScope.user==null}">
									<a href="${pageContext.request.contextPath}/safety/usertasklist.jsp">任务</a>
								</c:if>
							</li>
							<li>
								<a href="${pageContext.request.contextPath}/api/question/showAll.do">题库</a>
							</li>
							<li>
								<c:if test="${sessionScope.user==null}">
									<a href="${pageContext.request.contextPath}/login.jsp">登陆</a>
								</c:if>
								<c:if test="${sessionScope.user!=null}">
									<a href="${pageContext.request.contextPath}/safety/my.jsp">我的</a>
								</c:if>
							</li>
						</ul>
					</div>
				</nav>
    		</div>
    	</div>
        <div class="col-lg-12">
        	<c:if test="${sessionScope.user==null}">
				<a href="${pageContext.request.contextPath}/login.jsp" class="btn btn-primary">新增任务</a>
				<a href="${pageContext.request.contextPath}/login.jsp" class="btn btn-primary">今日任务</a>
			</c:if>
			<c:if test="${sessionScope.user!=null}">
				<a href="${pageContext.request.contextPath}/safety/usertaskadd.jsp" class="btn btn-primary">新增任务</a>
				<a href="${pageContext.request.contextPath}/api/task/show.do?day=today" class="btn btn-primary">今日任务</a>
			</c:if>
			<hr>
		</div>
    	<div class="col-lg-12">
            <table class="table">
            	<thead>
            		<tr>
            			<th>序号</th>
            			<th>用户</th>
            			<th>名称</th>
            			<th>数量</th>
            			<th>状态</th>
            			<th>日期</th>
            			<th>操作</th>
            		</tr>
            	</thead>
            	<tbody>
					<c:if test="${sessionScope.user==null}">
						<tr>
							<td colspan="7">登录后查看任务列表！点击<a href="${pageContext.request.contextPath}/login.jsp">登录</a></td>
						</tr>
					</c:if>
					
					<c:if test="${sessionScope.user!=null}">
						<c:if test="${empty tlist}">
							<tr>
								<td colspan="7">暂无任务！</td>
							</tr>
						</c:if>
						<c:if test="${tlist.size()>0}">
							<c:forEach items="${tlist}" var="t" varStatus="tv">
								<tr>
									<td>${tv.index+1}</td>
									<td>${sessionScope.user.nickname}</td>
									<td title="${t.title}">${t.title}</td>
									<td>${t.nums}</td>
									<td>${t.flag==1?"未完成":"已完成"}</td>
									<td title="${t.ctime}">${t.ctime}</td>
									<td>
										<a href="${pageContext.request.contextPath}/api/taskitem/show.do?to=taskitemlist.jsp&tid=${t.id}" class="btn btn-primary">详情</a>
										<c:if test="${t.flag != 1}">
											<a href="" class="btn btn-default">测试</a>
										</c:if>
										<c:if test="${t.flag == 1}">
											<a href="${pageContext.request.contextPath}/api/taskitem/show.do?to=usertaskdetail.jsp&tid=${t.id}" class="btn btn-primary">测试</a>
										</c:if>
									</td>
								</tr>
							</c:forEach>
						</c:if>
					</c:if>
            	</tbody>
            	<c:if test="${empty requestScope.day}">
					<tfoot>
					<tr>
						<td colspan="7" align="center">
							<ul class="pagination">
								<li>
									<a href="#">上一页</a>
								</li>
								<li>
									<a href="#">1</a>
								</li>
								<li>
									<a href="#">2</a>
								</li>
								<li>
									<a href="#">3</a>
								</li>
								<li>
									<a href="#">4</a>
								</li>
								<li>
									<a href="#">5</a>
								</li>
								<li>
									<a href="#">下一页</a>
								</li>
							</ul>
						</td>
					</tr>
					</tfoot>
				</c:if>
            </table>
    	</div>
    </div>
  </body>
</html>